/**
 *  This file is part of MunchLevel.
 *
 *  MunchLevel is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  MunchLevel is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with MunchLevel.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.munchlevel;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

import android.app.Application;
import android.graphics.Typeface;
import android.os.Environment;
import android.view.View;
import android.widget.TextView;

import com.gandulf.guilib.util.Debug;
import com.munchlevel.data.GameInfo;
import com.munchlevel.data.MunchkinConfiguration;

public class MunchLevelApplication extends Application {

	public static final String TAG = "MunchLevel";

	public static final File SD_DIR = new File(Environment.getExternalStorageDirectory(), "munchlife");

	public static final String AD_MOBS_ID = "a14ff31cd1c6a21";

	public static final int MINIMUM_GEAR = -99;
	public static final int MAXIMUM_GEAR = 99;

	private static MunchLevelApplication instance = null;

	private static Typeface font;

	public Set<String> confirmedDevices = new HashSet<String>();

	private MunchkinConfiguration configuration;

	private GameInfo gameInfo;

	@Override
	public void onCreate() {
		// provide an instance for our static accessors
		instance = this;
		Debug.setDebugTag(MunchLevelApplication.TAG);

		configuration = new MunchkinConfiguration(this);
	}

	public static MunchLevelApplication getInstance() {
		return instance;
	}

	public static void applyFont(View... views) {

		for (View v : views) {
			if (v instanceof TextView)
				((TextView) v).setTypeface(getFont());
		}
	}

	public static Typeface getFont() {
		if (font == null)
			font = Typeface.createFromAsset(instance.getBaseContext().getAssets(), "fonts/windlass.ttf");

		return font;
	}

	public GameInfo getGameInfo() {
		return gameInfo;
	}

	public void setGameInfo(GameInfo gameInfo) {
		this.gameInfo = gameInfo;
	}

	public MunchkinConfiguration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(MunchkinConfiguration configuration) {
		this.configuration = configuration;
	}

}
